﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.Prism.Regions;
using Microsoft.Practices.Prism.ViewModel;

namespace SearchModule.ViewModels
{
    public class GenericWebViewModel : NotificationObject, INavigationAware
    {
        public string URI { get; private set; }

        #region INavigationAware Members
        public bool IsNavigationTarget(NavigationContext navigationContext)
        {
            // Called to see if this view can handle the navigation request.
            // If it can, this view is activated.
            return true;
        }

        public void OnNavigatedFrom(NavigationContext navigationContext)
        {
            // Called when this view is deactivated as a result of navigation to another view.
        }

        public void OnNavigatedTo(NavigationContext navigationContext)
        {
            // Called to initialize this view during navigation.
            string targetURI = navigationContext.Parameters["uri"];
            if (!string.IsNullOrEmpty(targetURI))
            {
                URI = targetURI;
                RaisePropertyChanged("URI");
            }
        }
        #endregion
    }
}
